﻿module DocumentWindow

open Dom
open DocumentHost
open ScriptingExposedAttribute
open Uris

[<ScriptingExposed>]
type Console(host:IDocumentHost) =
    let _host = host

    [<ScriptingExposed>]
    member public this.log(msg:string) = 
        do _host.log(msg)


(*
    Instantiated for each document.
*)
type DocumentWindow(doc:Document, host:IDocumentHost) =
    let _doc = doc   
    let _host = host
    let _console = Console(host)
    //let _eventTracker = EventTracker()

    interface IWindow with
        member this.navigate(uri:HttpUrl) =
            _host.navigate(uri)

        member this.submit (uri:HttpUrl, httpMethod:string, encoding:string, data:(string*string) list) =
            _host.submit(uri, httpMethod, encoding, data)

        member this.log(txt) = 
            _host.log(txt)

    [<ScriptingExposed>]
    member public this.alert(msg:string) = 
        do System.Windows.MessageBox.Show(msg) |> ignore

    [<ScriptingExposed>]
    member public this.Console 
            with get() = 
                _console

